#include <iostream>
using namespace std;
using ll=long long;

int main() {

	int n,m;
	cin>>n>>m;
	ll nRet=n;
	for(int i=0;i<m-1;++i){
		nRet=(nRet*(n-1))%109;
	}
	cout<<nRet<<endl;
	
	return 0;
}
